<!-- HTML header for doxygen 1.8.6-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<title>OpenCV: cv::PCA Class Reference</title>
<link href="../../opencv.ico" rel="shortcut icon" type="image/x-icon" />
<link href="../../tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../jquery.js"></script>
<script type="text/javascript" src="../../dynsections.js"></script>
<script type="text/javascript" src="../../tutorial-utils.js"></script>
<link href="../../search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../search/searchdata.js"></script>
<script type="text/javascript" src="../../search/search.js"></script>
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    extensions: ["tex2jax.js", "TeX/AMSmath.js", "TeX/AMSsymbols.js"],
    jax: ["input/TeX","output/HTML-CSS"],
});
//<![CDATA[
MathJax.Hub.Config(
{
  TeX: {
      Macros: {
          matTT: [ "\\[ \\left|\\begin{array}{ccc} #1 & #2 & #3\\\\ #4 & #5 & #6\\\\ #7 & #8 & #9 \\end{array}\\right| \\]", 9],
          fork: ["\\left\\{ \\begin{array}{l l} #1 & \\mbox{#2}\\\\ #3 & \\mbox{#4}\\\\ \\end{array} \\right.", 4],
          forkthree: ["\\left\\{ \\begin{array}{l l} #1 & \\mbox{#2}\\\\ #3 & \\mbox{#4}\\\\ #5 & \\mbox{#6}\\\\ \\end{array} \\right.", 6],
          forkfour: ["\\left\\{ \\begin{array}{l l} #1 & \\mbox{#2}\\\\ #3 & \\mbox{#4}\\\\ #5 & \\mbox{#6}\\\\ #7 & \\mbox{#8}\\\\ \\end{array} \\right.", 8],
          vecthree: ["\\begin{bmatrix} #1\\\\ #2\\\\ #3 \\end{bmatrix}", 3],
          vecthreethree: ["\\begin{bmatrix} #1 & #2 & #3\\\\ #4 & #5 & #6\\\\ #7 & #8 & #9 \\end{bmatrix}", 9],
          cameramatrix: ["#1 = \\begin{bmatrix} f_x & 0 & c_x\\\\ 0 & f_y & c_y\\\\ 0 & 0 & 1 \\end{bmatrix}", 1],
          distcoeffs: ["(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6 [, s_1, s_2, s_3, s_4[, \\tau_x, \\tau_y]]]]) \\text{ of 4, 5, 8, 12 or 14 elements}"],
          distcoeffsfisheye: ["(k_1, k_2, k_3, k_4)"],
          hdotsfor: ["\\dots", 1],
          mathbbm: ["\\mathbb{#1}", 1],
          bordermatrix: ["\\matrix{#1}", 1]
      }
  }
}
);
//]]>
</script><script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js"></script>
<link href="../../doxygen.css" rel="stylesheet" type="text/css" />
<link href="../../stylesheet.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<!--#include virtual="/google-search.html"-->
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="../../opencv-logo-small.png"/></td>
  <td style="padding-left: 0.5em;">
   <div id="projectname">OpenCV
   &#160;<span id="projectnumber">4.5.2</span>
   </div>
   <div id="projectbrief">Open Source Computer Vision</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "../../search",false,'Search');
</script>
<script type="text/javascript" src="../../menudata.js"></script>
<script type="text/javascript" src="../../menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('../../',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="../../d2/d75/namespacecv.html">cv</a></li><li class="navelem"><a class="el" href="../../d3/d8d/classcv_1_1PCA.html">PCA</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#pub-types">Public Types</a> &#124;
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#pub-attribs">Public Attributes</a> &#124;
<a href="../../d6/d40/classcv_1_1PCA-members.html">List of all members</a>  </div>
  <div class="headertitle">
<div class="title">cv::PCA Class Reference<div class="ingroups"><a class="el" href="../../d0/de1/group__core.html">Core functionality</a> &raquo; <a class="el" href="../../d2/de8/group__core__array.html">Operations on arrays</a></div></div>  </div>
</div><!--header-->
<div class="contents">

<p>Principal Component Analysis.  
 <a href="../../d3/d8d/classcv_1_1PCA.html#details">More...</a></p>

<p><code>#include &lt;opencv2/core.hpp&gt;</code></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-types"></a>
Public Types</h2></td></tr>
<tr class="memitem:ae8a94a2add0555b0414e85c08ff67f50"><td class="memItemLeft" align="right" valign="top">enum &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d3/d8d/classcv_1_1PCA.html#ae8a94a2add0555b0414e85c08ff67f50">Flags</a> { <br />
&#160;&#160;<a class="el" href="../../d3/d8d/classcv_1_1PCA.html#ae8a94a2add0555b0414e85c08ff67f50a159399e962048f705645483ca16e9fd6">DATA_AS_ROW</a> = 0, 
<br />
&#160;&#160;<a class="el" href="../../d3/d8d/classcv_1_1PCA.html#ae8a94a2add0555b0414e85c08ff67f50a2c52b7c4c9721a3e04a1d6699e738093">DATA_AS_COL</a> = 1, 
<br />
&#160;&#160;<a class="el" href="../../d3/d8d/classcv_1_1PCA.html#ae8a94a2add0555b0414e85c08ff67f50a3449339c21160478c308f64a6a941030">USE_AVG</a> = 2
<br />
 }</td></tr>
<tr class="separator:ae8a94a2add0555b0414e85c08ff67f50"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:a50ad1a87273a258055a331d5a4c63ce4"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d3/d8d/classcv_1_1PCA.html#a50ad1a87273a258055a331d5a4c63ce4">PCA</a> ()</td></tr>
<tr class="memdesc:a50ad1a87273a258055a331d5a4c63ce4"><td class="mdescLeft">&#160;</td><td class="mdescRight">default constructor  <a href="#a50ad1a87273a258055a331d5a4c63ce4">More...</a><br /></td></tr>
<tr class="separator:a50ad1a87273a258055a331d5a4c63ce4"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a5a7400a3dd169deb4111231a61bc2575"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d3/d8d/classcv_1_1PCA.html#a5a7400a3dd169deb4111231a61bc2575">PCA</a> (<a class="el" href="../../dc/d84/group__core__basic.html#ga353a9de602fe76c709e12074a6f362ba">InputArray</a> data, <a class="el" href="../../dc/d84/group__core__basic.html#ga353a9de602fe76c709e12074a6f362ba">InputArray</a> <a class="el" href="../../d3/d8d/classcv_1_1PCA.html#a1bca9d1cc7808b7d08b2a046ee92cd11">mean</a>, int flags, int maxComponents=0)</td></tr>
<tr class="separator:a5a7400a3dd169deb4111231a61bc2575"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af44683b857883856418187f24d8d19a2"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d3/d8d/classcv_1_1PCA.html#af44683b857883856418187f24d8d19a2">PCA</a> (<a class="el" href="../../dc/d84/group__core__basic.html#ga353a9de602fe76c709e12074a6f362ba">InputArray</a> data, <a class="el" href="../../dc/d84/group__core__basic.html#ga353a9de602fe76c709e12074a6f362ba">InputArray</a> <a class="el" href="../../d3/d8d/classcv_1_1PCA.html#a1bca9d1cc7808b7d08b2a046ee92cd11">mean</a>, int flags, double retainedVariance)</td></tr>
<tr class="separator:af44683b857883856418187f24d8d19a2"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a5f84cfbdb25b9833cc1bfb5bd484ea79"><td class="memItemLeft" align="right" valign="top"><a class="el" href="../../d3/d63/classcv_1_1Mat.html">Mat</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d3/d8d/classcv_1_1PCA.html#a5f84cfbdb25b9833cc1bfb5bd484ea79">backProject</a> (<a class="el" href="../../dc/d84/group__core__basic.html#ga353a9de602fe76c709e12074a6f362ba">InputArray</a> vec) const</td></tr>
<tr class="memdesc:a5f84cfbdb25b9833cc1bfb5bd484ea79"><td class="mdescLeft">&#160;</td><td class="mdescRight">Reconstructs vectors from their PC projections.  <a href="#a5f84cfbdb25b9833cc1bfb5bd484ea79">More...</a><br /></td></tr>
<tr class="separator:a5f84cfbdb25b9833cc1bfb5bd484ea79"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a3b2dae725800de973be1135e92b1686a"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d3/d8d/classcv_1_1PCA.html#a3b2dae725800de973be1135e92b1686a">backProject</a> (<a class="el" href="../../dc/d84/group__core__basic.html#ga353a9de602fe76c709e12074a6f362ba">InputArray</a> vec, <a class="el" href="../../dc/d84/group__core__basic.html#gaad17fda1d0f0d1ee069aebb1df2913c0">OutputArray</a> result) const</td></tr>
<tr class="separator:a3b2dae725800de973be1135e92b1686a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a26e76331a68988144a403649c6b8af5c"><td class="memItemLeft" align="right" valign="top"><a class="el" href="../../d3/d8d/classcv_1_1PCA.html">PCA</a> &amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d3/d8d/classcv_1_1PCA.html#a26e76331a68988144a403649c6b8af5c">operator()</a> (<a class="el" href="../../dc/d84/group__core__basic.html#ga353a9de602fe76c709e12074a6f362ba">InputArray</a> data, <a class="el" href="../../dc/d84/group__core__basic.html#ga353a9de602fe76c709e12074a6f362ba">InputArray</a> <a class="el" href="../../d3/d8d/classcv_1_1PCA.html#a1bca9d1cc7808b7d08b2a046ee92cd11">mean</a>, int flags, int maxComponents=0)</td></tr>
<tr class="memdesc:a26e76331a68988144a403649c6b8af5c"><td class="mdescLeft">&#160;</td><td class="mdescRight">performs PCA  <a href="#a26e76331a68988144a403649c6b8af5c">More...</a><br /></td></tr>
<tr class="separator:a26e76331a68988144a403649c6b8af5c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aff68797b34e6edb162b0f5d1819b2e9f"><td class="memItemLeft" align="right" valign="top"><a class="el" href="../../d3/d8d/classcv_1_1PCA.html">PCA</a> &amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d3/d8d/classcv_1_1PCA.html#aff68797b34e6edb162b0f5d1819b2e9f">operator()</a> (<a class="el" href="../../dc/d84/group__core__basic.html#ga353a9de602fe76c709e12074a6f362ba">InputArray</a> data, <a class="el" href="../../dc/d84/group__core__basic.html#ga353a9de602fe76c709e12074a6f362ba">InputArray</a> <a class="el" href="../../d3/d8d/classcv_1_1PCA.html#a1bca9d1cc7808b7d08b2a046ee92cd11">mean</a>, int flags, double retainedVariance)</td></tr>
<tr class="separator:aff68797b34e6edb162b0f5d1819b2e9f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a67c9a3f8fe804f40be58c88a3ae73f41"><td class="memItemLeft" align="right" valign="top"><a class="el" href="../../d3/d63/classcv_1_1Mat.html">Mat</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d3/d8d/classcv_1_1PCA.html#a67c9a3f8fe804f40be58c88a3ae73f41">project</a> (<a class="el" href="../../dc/d84/group__core__basic.html#ga353a9de602fe76c709e12074a6f362ba">InputArray</a> vec) const</td></tr>
<tr class="memdesc:a67c9a3f8fe804f40be58c88a3ae73f41"><td class="mdescLeft">&#160;</td><td class="mdescRight">Projects vector(s) to the principal component subspace.  <a href="#a67c9a3f8fe804f40be58c88a3ae73f41">More...</a><br /></td></tr>
<tr class="separator:a67c9a3f8fe804f40be58c88a3ae73f41"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a0d02b263028cdf5267229f334020c632"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d3/d8d/classcv_1_1PCA.html#a0d02b263028cdf5267229f334020c632">project</a> (<a class="el" href="../../dc/d84/group__core__basic.html#ga353a9de602fe76c709e12074a6f362ba">InputArray</a> vec, <a class="el" href="../../dc/d84/group__core__basic.html#gaad17fda1d0f0d1ee069aebb1df2913c0">OutputArray</a> result) const</td></tr>
<tr class="separator:a0d02b263028cdf5267229f334020c632"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aa41a4bdd788b67e7e83de8c096f30816"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d3/d8d/classcv_1_1PCA.html#aa41a4bdd788b67e7e83de8c096f30816">read</a> (const <a class="el" href="../../de/dd9/classcv_1_1FileNode.html">FileNode</a> &amp;fn)</td></tr>
<tr class="memdesc:aa41a4bdd788b67e7e83de8c096f30816"><td class="mdescLeft">&#160;</td><td class="mdescRight">load <a class="el" href="../../d3/d8d/classcv_1_1PCA.html" title="Principal Component Analysis. ">PCA</a> objects  <a href="#aa41a4bdd788b67e7e83de8c096f30816">More...</a><br /></td></tr>
<tr class="separator:aa41a4bdd788b67e7e83de8c096f30816"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a8be99fa476731ff5429c241e9a92a57b"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d3/d8d/classcv_1_1PCA.html#a8be99fa476731ff5429c241e9a92a57b">write</a> (<a class="el" href="../../da/d56/classcv_1_1FileStorage.html">FileStorage</a> &amp;fs) const</td></tr>
<tr class="memdesc:a8be99fa476731ff5429c241e9a92a57b"><td class="mdescLeft">&#160;</td><td class="mdescRight">write <a class="el" href="../../d3/d8d/classcv_1_1PCA.html" title="Principal Component Analysis. ">PCA</a> objects  <a href="#a8be99fa476731ff5429c241e9a92a57b">More...</a><br /></td></tr>
<tr class="separator:a8be99fa476731ff5429c241e9a92a57b"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-attribs"></a>
Public Attributes</h2></td></tr>
<tr class="memitem:a1c9d34c02df49120474a4a366b971303"><td class="memItemLeft" align="right" valign="top"><a class="el" href="../../d3/d63/classcv_1_1Mat.html">Mat</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d3/d8d/classcv_1_1PCA.html#a1c9d34c02df49120474a4a366b971303">eigenvalues</a></td></tr>
<tr class="memdesc:a1c9d34c02df49120474a4a366b971303"><td class="mdescLeft">&#160;</td><td class="mdescRight">eigenvalues of the covariation matrix  <a href="#a1c9d34c02df49120474a4a366b971303">More...</a><br /></td></tr>
<tr class="separator:a1c9d34c02df49120474a4a366b971303"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a8fed85cf5f9d8bb9b17f031398cb74a0"><td class="memItemLeft" align="right" valign="top"><a class="el" href="../../d3/d63/classcv_1_1Mat.html">Mat</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d3/d8d/classcv_1_1PCA.html#a8fed85cf5f9d8bb9b17f031398cb74a0">eigenvectors</a></td></tr>
<tr class="memdesc:a8fed85cf5f9d8bb9b17f031398cb74a0"><td class="mdescLeft">&#160;</td><td class="mdescRight">eigenvectors of the covariation matrix  <a href="#a8fed85cf5f9d8bb9b17f031398cb74a0">More...</a><br /></td></tr>
<tr class="separator:a8fed85cf5f9d8bb9b17f031398cb74a0"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a1bca9d1cc7808b7d08b2a046ee92cd11"><td class="memItemLeft" align="right" valign="top"><a class="el" href="../../d3/d63/classcv_1_1Mat.html">Mat</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="../../d3/d8d/classcv_1_1PCA.html#a1bca9d1cc7808b7d08b2a046ee92cd11">mean</a></td></tr>
<tr class="memdesc:a1bca9d1cc7808b7d08b2a046ee92cd11"><td class="mdescLeft">&#160;</td><td class="mdescRight">mean value subtracted before the projection and added after the back projection  <a href="#a1bca9d1cc7808b7d08b2a046ee92cd11">More...</a><br /></td></tr>
<tr class="separator:a1bca9d1cc7808b7d08b2a046ee92cd11"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>Principal Component Analysis. </p>
<p>The class is used to calculate a special basis for a set of vectors. The basis will consist of eigenvectors of the covariance matrix calculated from the input set of vectors. The class PCA can also transform vectors to/from the new coordinate space defined by the basis. Usually, in this new coordinate system, each vector from the original set (and any linear combination of such vectors) can be quite accurately approximated by taking its first few components, corresponding to the eigenvectors of the largest eigenvalues of the covariance matrix. Geometrically it means that you calculate a projection of the vector to a subspace formed by a few eigenvectors corresponding to the dominant eigenvalues of the covariance matrix. And usually such a projection is very close to the original vector. So, you can represent the original vector from a high-dimensional space with a much shorter vector consisting of the projected vector's coordinates in the subspace. Such a transformation is also known as Karhunen-Loeve Transform, or KLT. See <a href="http://en.wikipedia.org/wiki/Principal_component_analysis">http://en.wikipedia.org/wiki/Principal_component_analysis</a></p>
<p>The sample below is the function that takes two matrices. The first function stores a set of vectors (a row per vector) that is used to calculate <a class="el" href="../../d3/d8d/classcv_1_1PCA.html" title="Principal Component Analysis. ">PCA</a>. The second function stores another "test" set of vectors (a row per vector). First, these vectors are compressed with <a class="el" href="../../d3/d8d/classcv_1_1PCA.html" title="Principal Component Analysis. ">PCA</a>, then reconstructed back, and then the reconstruction error norm is computed and printed for each vector. :</p>
<div class="fragment"><div class="line"><span class="keyword">using namespace </span><a class="code" href="../../d2/d75/namespacecv.html">cv</a>;</div><div class="line"></div><div class="line"><a class="code" href="../../d3/d8d/classcv_1_1PCA.html">PCA</a> compressPCA(<span class="keyword">const</span> <a class="code" href="../../d3/d63/classcv_1_1Mat.html">Mat</a>&amp; pcaset, <span class="keywordtype">int</span> maxComponents,</div><div class="line">                <span class="keyword">const</span> <a class="code" href="../../d3/d63/classcv_1_1Mat.html">Mat</a>&amp; testset, <a class="code" href="../../d3/d63/classcv_1_1Mat.html">Mat</a>&amp; compressed)</div><div class="line">{</div><div class="line">    <a class="code" href="../../d3/d8d/classcv_1_1PCA.html">PCA</a> pca(pcaset, <span class="comment">// pass the data</span></div><div class="line">            <a class="code" href="../../d3/d63/classcv_1_1Mat.html">Mat</a>(), <span class="comment">// we do not have a pre-computed mean vector,</span></div><div class="line">                   <span class="comment">// so let the PCA engine to compute it</span></div><div class="line">            <a class="code" href="../../d3/d8d/classcv_1_1PCA.html#ae8a94a2add0555b0414e85c08ff67f50a159399e962048f705645483ca16e9fd6">PCA::DATA_AS_ROW</a>, <span class="comment">// indicate that the vectors</span></div><div class="line">                                <span class="comment">// are stored as matrix rows</span></div><div class="line">                                <span class="comment">// (use PCA::DATA_AS_COL if the vectors are</span></div><div class="line">                                <span class="comment">// the matrix columns)</span></div><div class="line">            maxComponents <span class="comment">// specify, how many principal components to retain</span></div><div class="line">            );</div><div class="line">    <span class="comment">// if there is no test data, just return the computed basis, ready-to-use</span></div><div class="line">    <span class="keywordflow">if</span>( !testset.<a class="code" href="../../d3/d63/classcv_1_1Mat.html#a4d33bed1c850265370d2af0ff02e1564">data</a> )</div><div class="line">        <span class="keywordflow">return</span> pca;</div><div class="line">    <a class="code" href="../../db/de0/group__core__utils.html#gaf62bcd90f70e275191ab95136d85906b">CV_Assert</a>( testset.<a class="code" href="../../d3/d63/classcv_1_1Mat.html#aa3e5a47585c9ef6a0842556739155e3e">cols</a> == pcaset.<a class="code" href="../../d3/d63/classcv_1_1Mat.html#aa3e5a47585c9ef6a0842556739155e3e">cols</a> );</div><div class="line"></div><div class="line">    compressed.<a class="code" href="../../d3/d63/classcv_1_1Mat.html#a55ced2c8d844d683ea9a725c60037ad0">create</a>(testset.<a class="code" href="../../d3/d63/classcv_1_1Mat.html#abed816466c45234254d25bc59c31245e">rows</a>, maxComponents, testset.<a class="code" href="../../d3/d63/classcv_1_1Mat.html#af2d2652e552d7de635988f18a84b53e5">type</a>());</div><div class="line"></div><div class="line">    <a class="code" href="../../d3/d63/classcv_1_1Mat.html">Mat</a> reconstructed;</div><div class="line">    <span class="keywordflow">for</span>( <span class="keywordtype">int</span> i = 0; i &lt; testset.<a class="code" href="../../d3/d63/classcv_1_1Mat.html#abed816466c45234254d25bc59c31245e">rows</a>; i++ )</div><div class="line">    {</div><div class="line">        <a class="code" href="../../d3/d63/classcv_1_1Mat.html">Mat</a> vec = testset.<a class="code" href="../../d3/d63/classcv_1_1Mat.html#a4b22e1c23af7a7f2eef8fa478cfa7434">row</a>(i), coeffs = compressed.<a class="code" href="../../d3/d63/classcv_1_1Mat.html#a4b22e1c23af7a7f2eef8fa478cfa7434">row</a>(i), reconstructed;</div><div class="line">        <span class="comment">// compress the vector, the result will be stored</span></div><div class="line">        <span class="comment">// in the i-th row of the output matrix</span></div><div class="line">        pca.project(vec, coeffs);</div><div class="line">        <span class="comment">// and then reconstruct it</span></div><div class="line">        pca.backProject(coeffs, reconstructed);</div><div class="line">        <span class="comment">// and measure the error</span></div><div class="line">        printf(<span class="stringliteral">&quot;%d. diff = %g\n&quot;</span>, i, <a class="code" href="../../dc/d84/group__core__basic.html#ga4e556cb8ad35a643a1ea66e035711bb9">norm</a>(vec, reconstructed, <a class="code" href="../../d2/de8/group__core__array.html#ggad12cefbcb5291cf958a85b4b67b6149fa7bacbe84d400336a8f26297d8e80e3a2">NORM_L2</a>));</div><div class="line">    }</div><div class="line">    <span class="keywordflow">return</span> pca;</div><div class="line">}</div></div><!-- fragment --> <dl class="section see"><dt>See also</dt><dd><a class="el" href="../../d2/de8/group__core__array.html#gae6ffa9354633f984246945d52823165d" title="Calculates the covariance matrix of a set of vectors. ">calcCovarMatrix</a>, <a class="el" href="../../d2/de8/group__core__array.html#gadc4e49f8f7a155044e3be1b9e3b270ab" title="Calculates the product of a matrix and its transposition. ">mulTransposed</a>, <a class="el" href="../../df/df7/classcv_1_1SVD.html" title="Singular Value Decomposition. ">SVD</a>, <a class="el" href="../../d2/de8/group__core__array.html#gadd6cf9baf2b8b704a11b5f04aaf4f39d" title="Performs a forward or inverse Discrete Fourier transform of a 1D or 2D floating-point array...">dft</a>, <a class="el" href="../../d2/de8/group__core__array.html#ga85aad4d668c01fbd64825f589e3696d4" title="Performs a forward or inverse discrete Cosine transform of 1D or 2D array. ">dct</a> </dd></dl>
<dl><dt><b>Examples: </b></dt><dd><a class="el" href="../../d3/db0/samples_2cpp_2pca_8cpp-example.html#_a15">samples/cpp/pca.cpp</a>, and <a class="el" href="../../da/d94/samples_2cpp_2tutorial_code_2ml_2introduction_to_pca_2introduction_to_pca_8cpp-example.html#_a17">samples/cpp/tutorial_code/ml/introduction_to_pca/introduction_to_pca.cpp</a>.</dd>
</dl></div><h2 class="groupheader">Member Enumeration Documentation</h2>
<a id="ae8a94a2add0555b0414e85c08ff67f50"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ae8a94a2add0555b0414e85c08ff67f50">&#9670;&nbsp;</a></span>Flags</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">enum <a class="el" href="../../d3/d8d/classcv_1_1PCA.html#ae8a94a2add0555b0414e85c08ff67f50">cv::PCA::Flags</a></td>
        </tr>
      </table>
</div><div class="memdoc">
<table class="fieldtable">
<tr><th colspan="2">Enumerator</th></tr><tr><td class="fieldname"><a id="ae8a94a2add0555b0414e85c08ff67f50a159399e962048f705645483ca16e9fd6"></a>DATA_AS_ROW&#160;</td><td class="fielddoc"><p>indicates that the input samples are stored as matrix rows </p>
</td></tr>
<tr><td class="fieldname"><a id="ae8a94a2add0555b0414e85c08ff67f50a2c52b7c4c9721a3e04a1d6699e738093"></a>DATA_AS_COL&#160;</td><td class="fielddoc"><p>indicates that the input samples are stored as matrix columns </p>
</td></tr>
<tr><td class="fieldname"><a id="ae8a94a2add0555b0414e85c08ff67f50a3449339c21160478c308f64a6a941030"></a>USE_AVG&#160;</td><td class="fielddoc"></td></tr>
</table>

</div>
</div>
<h2 class="groupheader">Constructor &amp; Destructor Documentation</h2>
<a id="a50ad1a87273a258055a331d5a4c63ce4"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a50ad1a87273a258055a331d5a4c63ce4">&#9670;&nbsp;</a></span>PCA() <span class="overload">[1/3]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">cv::PCA::PCA </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>default constructor </p>
<p>The default constructor initializes an empty PCA structure. The other constructors initialize the structure and call <a class="el" href="../../d3/d8d/classcv_1_1PCA.html#a26e76331a68988144a403649c6b8af5c" title="performs PCA ">PCA::operator()()</a>. </p>

</div>
</div>
<a id="a5a7400a3dd169deb4111231a61bc2575"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a5a7400a3dd169deb4111231a61bc2575">&#9670;&nbsp;</a></span>PCA() <span class="overload">[2/3]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">cv::PCA::PCA </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="../../dc/d84/group__core__basic.html#ga353a9de602fe76c709e12074a6f362ba">InputArray</a>&#160;</td>
          <td class="paramname"><em>data</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="../../dc/d84/group__core__basic.html#ga353a9de602fe76c709e12074a6f362ba">InputArray</a>&#160;</td>
          <td class="paramname"><em>mean</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>flags</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>maxComponents</em> = <code>0</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">data</td><td>input samples stored as matrix rows or matrix columns. </td></tr>
    <tr><td class="paramname">mean</td><td>optional mean value; if the matrix is empty (<code><a class="el" href="../../dc/d84/group__core__basic.html#gad9287b23bba2fed753b36ef561ae7346">noArray()</a></code>), the mean is computed from the data. </td></tr>
    <tr><td class="paramname">flags</td><td>operation flags; currently the parameter is only used to specify the data layout (<a class="el" href="../../d3/d8d/classcv_1_1PCA.html#ae8a94a2add0555b0414e85c08ff67f50">PCA::Flags</a>) </td></tr>
    <tr><td class="paramname">maxComponents</td><td>maximum number of components that PCA should retain; by default, all the components are retained. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="af44683b857883856418187f24d8d19a2"></a>
<h2 class="memtitle"><span class="permalink"><a href="#af44683b857883856418187f24d8d19a2">&#9670;&nbsp;</a></span>PCA() <span class="overload">[3/3]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">cv::PCA::PCA </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="../../dc/d84/group__core__basic.html#ga353a9de602fe76c709e12074a6f362ba">InputArray</a>&#160;</td>
          <td class="paramname"><em>data</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="../../dc/d84/group__core__basic.html#ga353a9de602fe76c709e12074a6f362ba">InputArray</a>&#160;</td>
          <td class="paramname"><em>mean</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>flags</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">double&#160;</td>
          <td class="paramname"><em>retainedVariance</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">data</td><td>input samples stored as matrix rows or matrix columns. </td></tr>
    <tr><td class="paramname">mean</td><td>optional mean value; if the matrix is empty (<a class="el" href="../../dc/d84/group__core__basic.html#gad9287b23bba2fed753b36ef561ae7346">noArray()</a>), the mean is computed from the data. </td></tr>
    <tr><td class="paramname">flags</td><td>operation flags; currently the parameter is only used to specify the data layout (<a class="el" href="../../d3/d8d/classcv_1_1PCA.html#ae8a94a2add0555b0414e85c08ff67f50">PCA::Flags</a>) </td></tr>
    <tr><td class="paramname">retainedVariance</td><td>Percentage of variance that <a class="el" href="../../d3/d8d/classcv_1_1PCA.html" title="Principal Component Analysis. ">PCA</a> should retain. Using this parameter will let the <a class="el" href="../../d3/d8d/classcv_1_1PCA.html" title="Principal Component Analysis. ">PCA</a> decided how many components to retain but it will always keep at least 2. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a id="a5f84cfbdb25b9833cc1bfb5bd484ea79"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a5f84cfbdb25b9833cc1bfb5bd484ea79">&#9670;&nbsp;</a></span>backProject() <span class="overload">[1/2]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="../../d3/d63/classcv_1_1Mat.html">Mat</a> cv::PCA::backProject </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="../../dc/d84/group__core__basic.html#ga353a9de602fe76c709e12074a6f362ba">InputArray</a>&#160;</td>
          <td class="paramname"><em>vec</em></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Reconstructs vectors from their PC projections. </p>
<p>The methods are inverse operations to <a class="el" href="../../d3/d8d/classcv_1_1PCA.html#a67c9a3f8fe804f40be58c88a3ae73f41" title="Projects vector(s) to the principal component subspace. ">PCA::project</a>. They take PC coordinates of projected vectors and reconstruct the original vectors. Unless all the principal components have been retained, the reconstructed vectors are different from the originals. But typically, the difference is small if the number of components is large enough (but still much smaller than the original vector dimensionality). As a result, <a class="el" href="../../d3/d8d/classcv_1_1PCA.html" title="Principal Component Analysis. ">PCA</a> is used. </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">vec</td><td>coordinates of the vectors in the principal component subspace, the layout and size are the same as of <a class="el" href="../../d3/d8d/classcv_1_1PCA.html#a67c9a3f8fe804f40be58c88a3ae73f41" title="Projects vector(s) to the principal component subspace. ">PCA::project</a> output vectors. </td></tr>
  </table>
  </dd>
</dl>
<dl><dt><b>Examples: </b></dt><dd><a class="el" href="../../d3/db0/samples_2cpp_2pca_8cpp-example.html#a27">samples/cpp/pca.cpp</a>.</dd>
</dl>
</div>
</div>
<a id="a3b2dae725800de973be1135e92b1686a"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a3b2dae725800de973be1135e92b1686a">&#9670;&nbsp;</a></span>backProject() <span class="overload">[2/2]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void cv::PCA::backProject </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="../../dc/d84/group__core__basic.html#ga353a9de602fe76c709e12074a6f362ba">InputArray</a>&#160;</td>
          <td class="paramname"><em>vec</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="../../dc/d84/group__core__basic.html#gaad17fda1d0f0d1ee069aebb1df2913c0">OutputArray</a>&#160;</td>
          <td class="paramname"><em>result</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td> const</td>
        </tr>
      </table>
</div><div class="memdoc">
<p>This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">vec</td><td>coordinates of the vectors in the principal component subspace, the layout and size are the same as of <a class="el" href="../../d3/d8d/classcv_1_1PCA.html#a67c9a3f8fe804f40be58c88a3ae73f41" title="Projects vector(s) to the principal component subspace. ">PCA::project</a> output vectors. </td></tr>
    <tr><td class="paramname">result</td><td>reconstructed vectors; the layout and size are the same as of <a class="el" href="../../d3/d8d/classcv_1_1PCA.html#a67c9a3f8fe804f40be58c88a3ae73f41" title="Projects vector(s) to the principal component subspace. ">PCA::project</a> input vectors. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="a26e76331a68988144a403649c6b8af5c"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a26e76331a68988144a403649c6b8af5c">&#9670;&nbsp;</a></span>operator()() <span class="overload">[1/2]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="../../d3/d8d/classcv_1_1PCA.html">PCA</a>&amp; cv::PCA::operator() </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="../../dc/d84/group__core__basic.html#ga353a9de602fe76c709e12074a6f362ba">InputArray</a>&#160;</td>
          <td class="paramname"><em>data</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="../../dc/d84/group__core__basic.html#ga353a9de602fe76c709e12074a6f362ba">InputArray</a>&#160;</td>
          <td class="paramname"><em>mean</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>flags</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>maxComponents</em> = <code>0</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>performs PCA </p>
<p>The operator performs PCA of the supplied dataset. It is safe to reuse the same <a class="el" href="../../d3/d8d/classcv_1_1PCA.html" title="Principal Component Analysis. ">PCA</a> structure for multiple datasets. That is, if the structure has been previously used with another dataset, the existing internal data is reclaimed and the new <a class="el" href="../../d3/d8d/classcv_1_1PCA.html#a1c9d34c02df49120474a4a366b971303">eigenvalues</a>, <a class="el" href="../../d3/d8d/classcv_1_1PCA.html#a8fed85cf5f9d8bb9b17f031398cb74a0">eigenvectors</a> and <a class="el" href="../../d3/d8d/classcv_1_1PCA.html#a1bca9d1cc7808b7d08b2a046ee92cd11">mean</a> are allocated and computed.</p>
<p>The computed <a class="el" href="../../d3/d8d/classcv_1_1PCA.html#a1c9d34c02df49120474a4a366b971303">eigenvalues</a> are sorted from the largest to the smallest and the corresponding <a class="el" href="../../d3/d8d/classcv_1_1PCA.html#a8fed85cf5f9d8bb9b17f031398cb74a0">eigenvectors</a> are stored as eigenvectors rows.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">data</td><td>input samples stored as the matrix rows or as the matrix columns. </td></tr>
    <tr><td class="paramname">mean</td><td>optional mean value; if the matrix is empty (<a class="el" href="../../dc/d84/group__core__basic.html#gad9287b23bba2fed753b36ef561ae7346">noArray()</a>), the mean is computed from the data. </td></tr>
    <tr><td class="paramname">flags</td><td>operation flags; currently the parameter is only used to specify the data layout. (Flags) </td></tr>
    <tr><td class="paramname">maxComponents</td><td>maximum number of components that <a class="el" href="../../d3/d8d/classcv_1_1PCA.html" title="Principal Component Analysis. ">PCA</a> should retain; by default, all the components are retained. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="aff68797b34e6edb162b0f5d1819b2e9f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aff68797b34e6edb162b0f5d1819b2e9f">&#9670;&nbsp;</a></span>operator()() <span class="overload">[2/2]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="../../d3/d8d/classcv_1_1PCA.html">PCA</a>&amp; cv::PCA::operator() </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="../../dc/d84/group__core__basic.html#ga353a9de602fe76c709e12074a6f362ba">InputArray</a>&#160;</td>
          <td class="paramname"><em>data</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="../../dc/d84/group__core__basic.html#ga353a9de602fe76c709e12074a6f362ba">InputArray</a>&#160;</td>
          <td class="paramname"><em>mean</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>flags</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">double&#160;</td>
          <td class="paramname"><em>retainedVariance</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">data</td><td>input samples stored as the matrix rows or as the matrix columns. </td></tr>
    <tr><td class="paramname">mean</td><td>optional mean value; if the matrix is empty (<a class="el" href="../../dc/d84/group__core__basic.html#gad9287b23bba2fed753b36ef561ae7346">noArray()</a>), the mean is computed from the data. </td></tr>
    <tr><td class="paramname">flags</td><td>operation flags; currently the parameter is only used to specify the data layout. (<a class="el" href="../../d3/d8d/classcv_1_1PCA.html#ae8a94a2add0555b0414e85c08ff67f50">PCA::Flags</a>) </td></tr>
    <tr><td class="paramname">retainedVariance</td><td>Percentage of variance that PCA should retain. Using this parameter will let the PCA decided how many components to retain but it will always keep at least 2. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="a67c9a3f8fe804f40be58c88a3ae73f41"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a67c9a3f8fe804f40be58c88a3ae73f41">&#9670;&nbsp;</a></span>project() <span class="overload">[1/2]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="../../d3/d63/classcv_1_1Mat.html">Mat</a> cv::PCA::project </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="../../dc/d84/group__core__basic.html#ga353a9de602fe76c709e12074a6f362ba">InputArray</a>&#160;</td>
          <td class="paramname"><em>vec</em></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Projects vector(s) to the principal component subspace. </p>
<p>The methods project one or more vectors to the principal component subspace, where each vector projection is represented by coefficients in the principal component basis. The first form of the method returns the matrix that the second form writes to the result. So the first form can be used as a part of expression while the second form can be more efficient in a processing loop. </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">vec</td><td>input vector(s); must have the same dimensionality and the same layout as the input data used at PCA phase, that is, if DATA_AS_ROW are specified, then <code>vec.cols==data.cols</code> (vector dimensionality) and <code>vec.rows</code> is the number of vectors to project, and the same is true for the <a class="el" href="../../d3/d8d/classcv_1_1PCA.html#ae8a94a2add0555b0414e85c08ff67f50a2c52b7c4c9721a3e04a1d6699e738093" title="indicates that the input samples are stored as matrix columns ">PCA::DATA_AS_COL</a> case. </td></tr>
  </table>
  </dd>
</dl>
<dl><dt><b>Examples: </b></dt><dd><a class="el" href="../../d3/db0/samples_2cpp_2pca_8cpp-example.html#a26">samples/cpp/pca.cpp</a>.</dd>
</dl>
</div>
</div>
<a id="a0d02b263028cdf5267229f334020c632"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a0d02b263028cdf5267229f334020c632">&#9670;&nbsp;</a></span>project() <span class="overload">[2/2]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void cv::PCA::project </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="../../dc/d84/group__core__basic.html#ga353a9de602fe76c709e12074a6f362ba">InputArray</a>&#160;</td>
          <td class="paramname"><em>vec</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="../../dc/d84/group__core__basic.html#gaad17fda1d0f0d1ee069aebb1df2913c0">OutputArray</a>&#160;</td>
          <td class="paramname"><em>result</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td> const</td>
        </tr>
      </table>
</div><div class="memdoc">
<p>This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">vec</td><td>input vector(s); must have the same dimensionality and the same layout as the input data used at <a class="el" href="../../d3/d8d/classcv_1_1PCA.html" title="Principal Component Analysis. ">PCA</a> phase, that is, if DATA_AS_ROW are specified, then <code>vec.cols==data.cols</code> (vector dimensionality) and <code>vec.rows</code> is the number of vectors to project, and the same is true for the <a class="el" href="../../d3/d8d/classcv_1_1PCA.html#ae8a94a2add0555b0414e85c08ff67f50a2c52b7c4c9721a3e04a1d6699e738093" title="indicates that the input samples are stored as matrix columns ">PCA::DATA_AS_COL</a> case. </td></tr>
    <tr><td class="paramname">result</td><td>output vectors; in case of <a class="el" href="../../d3/d8d/classcv_1_1PCA.html#ae8a94a2add0555b0414e85c08ff67f50a2c52b7c4c9721a3e04a1d6699e738093" title="indicates that the input samples are stored as matrix columns ">PCA::DATA_AS_COL</a>, the output matrix has as many columns as the number of input vectors, this means that <code>result.cols==vec.cols</code> and the number of rows match the number of principal components (for example, <code>maxComponents</code> parameter passed to the constructor). </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="aa41a4bdd788b67e7e83de8c096f30816"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aa41a4bdd788b67e7e83de8c096f30816">&#9670;&nbsp;</a></span>read()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void cv::PCA::read </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="../../de/dd9/classcv_1_1FileNode.html">FileNode</a> &amp;&#160;</td>
          <td class="paramname"><em>fn</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>load <a class="el" href="../../d3/d8d/classcv_1_1PCA.html" title="Principal Component Analysis. ">PCA</a> objects </p>
<p>Loads <a class="el" href="../../d3/d8d/classcv_1_1PCA.html#a1c9d34c02df49120474a4a366b971303">eigenvalues</a> <a class="el" href="../../d3/d8d/classcv_1_1PCA.html#a8fed85cf5f9d8bb9b17f031398cb74a0">eigenvectors</a> and <a class="el" href="../../d3/d8d/classcv_1_1PCA.html#a1bca9d1cc7808b7d08b2a046ee92cd11">mean</a> from specified <a class="el" href="../../de/dd9/classcv_1_1FileNode.html" title="File Storage Node class. ">FileNode</a> </p>

</div>
</div>
<a id="a8be99fa476731ff5429c241e9a92a57b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a8be99fa476731ff5429c241e9a92a57b">&#9670;&nbsp;</a></span>write()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void cv::PCA::write </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="../../da/d56/classcv_1_1FileStorage.html">FileStorage</a> &amp;&#160;</td>
          <td class="paramname"><em>fs</em></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>write <a class="el" href="../../d3/d8d/classcv_1_1PCA.html" title="Principal Component Analysis. ">PCA</a> objects </p>
<p>Writes <a class="el" href="../../d3/d8d/classcv_1_1PCA.html#a1c9d34c02df49120474a4a366b971303">eigenvalues</a> <a class="el" href="../../d3/d8d/classcv_1_1PCA.html#a8fed85cf5f9d8bb9b17f031398cb74a0">eigenvectors</a> and <a class="el" href="../../d3/d8d/classcv_1_1PCA.html#a1bca9d1cc7808b7d08b2a046ee92cd11">mean</a> to specified <a class="el" href="../../da/d56/classcv_1_1FileStorage.html" title="XML/YAML/JSON file storage class that encapsulates all the information necessary for writing or readi...">FileStorage</a> </p>

</div>
</div>
<h2 class="groupheader">Member Data Documentation</h2>
<a id="a1c9d34c02df49120474a4a366b971303"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a1c9d34c02df49120474a4a366b971303">&#9670;&nbsp;</a></span>eigenvalues</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="../../d3/d63/classcv_1_1Mat.html">Mat</a> cv::PCA::eigenvalues</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>eigenvalues of the covariation matrix </p>

</div>
</div>
<a id="a8fed85cf5f9d8bb9b17f031398cb74a0"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a8fed85cf5f9d8bb9b17f031398cb74a0">&#9670;&nbsp;</a></span>eigenvectors</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="../../d3/d63/classcv_1_1Mat.html">Mat</a> cv::PCA::eigenvectors</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>eigenvectors of the covariation matrix </p>

</div>
</div>
<a id="a1bca9d1cc7808b7d08b2a046ee92cd11"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a1bca9d1cc7808b7d08b2a046ee92cd11">&#9670;&nbsp;</a></span>mean</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="../../d3/d63/classcv_1_1Mat.html">Mat</a> cv::PCA::mean</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>mean value subtracted before the projection and added after the back projection </p>

</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li>opencv2/<a class="el" href="../../d0/d9c/core_2include_2opencv2_2core_8hpp.html">core.hpp</a></li>
</ul>
</div><!-- contents -->
<!-- HTML footer for doxygen 1.8.6-->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Fri Apr 2 2021 11:36:43 for OpenCV by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="../../doxygen.png" alt="doxygen"/>
</a> 1.8.13
</small></address>
<script type="text/javascript">
//<![CDATA[
addTutorialsButtons();
//]]>
</script>
</body>
</html>
